package org.graduation.recruitment.entity.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.graduation.recruitment.entity.enums.EducationLevel;
import org.graduation.recruitment.entity.enums.JobType;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Job {
    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;
    private String name;
    private Long enterpriseId;
    private String enterpriseName;
    private Date createdDate;
    private Date updatedDate;

    // 招聘类型：全职、兼职、实习
    @TableField(exist = false)
    private JobType JobType;
    @TableField(value = "job_type")
    private String JobTypeStr;
    // 岗位描述
    private String description;
    // 岗位要求
    private String requirements;
    // 学历要求
    @TableField(exist = false)
    private EducationLevel educationalRequirements;
    @TableField(value = "educational_requirements")
    private String educationalRequirementsStr;
    // 工作地址
    private String workAddress;
    // 优先专业
    private String preferredMajors;

    // 面议薪资，面议薪资将不会存储最低最高薪资和薪资单位。
    private boolean faceTalkSalary;
    private Integer minSalary;
    private Integer MaxSalary;
    //薪资单位，千，万。
    private String minSalaryUnit;
    private String maxSalaryUnit;
    // 计薪时间，小时、天、周、月、年
    private String salaryTime;

    @TableField(value = "is_delete")
    private boolean logicDelete;

    public void setJobType(String jobTypeStr) {
        this.JobType = org.graduation.recruitment.entity.enums.JobType.of(jobTypeStr);
        if (this.JobType != null) {
            setJobTypeStr(this.JobType.toString());
        }
    }

    public void setEducationalRequirements(String educationalRequirementsStr) {
        this.educationalRequirements = org.graduation.recruitment.entity.enums.EducationLevel.of(educationalRequirementsStr);
        if (this.educationalRequirements != null) {
            setEducationalRequirementsStr(this.educationalRequirements.toString());
        }
    }


    public void setJobTypeStr(String jobTypeStr) {
        this.JobTypeStr = jobTypeStr;
        this.JobType = org.graduation.recruitment.entity.enums.JobType.of(jobTypeStr);
    }

    public void setEducationalRequirementsStr(String educationalRequirementsStr) {
        this.educationalRequirementsStr = educationalRequirementsStr;
        this.educationalRequirements = org.graduation.recruitment.entity.enums.EducationLevel.of(educationalRequirementsStr);
    }
}
